<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/3/15
 * Time: 19:17
 */

namespace Admin\Controller;
use Think\Controller;

class LoginController extends Controller
{

    public function chkcode(){
        $Verify = new \Think\Verify(array(
            'fontSize' => 30,
            'length'   => 3,
            'useNoise' => ture,
        ));
        $Verify->entry();
    }
    public function login() {
        if (IS_POST){
            $model = D('Admin');
            if ($model->validate($model->_login_validate)->create(I('post.'))){
                //
                if ($model->login()) {
                    $this->success('登录成功!',U('Index/Index'));
                    exit;
                }
            }
            $this->error($model->getError());
        }
        $this->display();
    }

    public function logout(){
        $model = D('Admin');
        $model->logout();
        redirect('login');
    }
}